VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsTiposUso"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Dim vSQL As String

Public pNumError As Long
Public pDesError As String
Public pCanReg As Long
Public pRS As ADODB.Recordset
Public pIdDevuelto As Long

Private vIdTiposUso As Long

Public Property Let IdTiposUso(ByVal VData As Long)
    vIdTiposUso = VData
End Property
Public Property Get IdTiposUso() As Long
    IdTiposUso = vIdTiposUso
End Property

Private Sub AsignarValores(Optional ByVal rs As ADODB.Recordset, Optional pNoAsigRs As Boolean)
    If Not pNoAsigRs Then
        Set Me.pRS = rs
    End If
    Me.pCanReg = objCnxAeros.pCanReg
    Me.pDesError = objCnxAeros.pDesError
    Me.pIdDevuelto = objCnxAeros.pUltIdenOtor
    Me.pNumError = objCnxAeros.pNumError
End Sub

Public Function sel_TiposUso(Optional ByVal nombreTiposUso)
Dim rs As New ADODB.Recordset
Dim strSQL As String

    If Not IsMissing(nombreTiposUso) Then
        strSQL = "SELECT id_tipo_uso,tipo_uso From tipos_uso WHERE fecha_baja is null AND tipo_uso like '%" & nombreTiposUso & "%' ORDER BY tipo_uso"
    Else
        strSQL = "SELECT id_tipo_uso,tipo_uso From tipos_uso WHERE fecha_baja is null ORDER BY tipo_uso"
    End If
    
    Set rs = objCnxAeros.EjecutarConsulta(strSQL)
    AsignarValores rs

End Function

Public Function ActualizarTiposUso_by_ID(ByVal id_tipo_uso As Long, tipo_uso As String) As Boolean
Dim strSQL As String

strSQL = " UPDATE tipos_uso SET tipo_uso='" & tipo_uso & _
                                        "' WHERE tipos_uso.id_tipo_uso =" & id_tipo_uso
    
                                        
    If objCnxAeros.EjecutarComando(strSQL) Then
        ActualizarTiposUso_by_ID = True
    Else
        ActualizarTiposUso_by_ID = False
    End If

End Function

Public Function BorrarTiposUso_by_ID(ByVal ID As Long)
Dim strSQL As String

    strSQL = " UPDATE tipos_uso SET fecha_baja ='" & Date & "'" & _
             " WHERE tipos_uso.id_tipo_uso =" & ID

    If objCnxAeros.EjecutarComando(strSQL) Then
        BorrarTiposUso_by_ID = True
    Else
        BorrarTiposUso_by_ID = False
    End If

End Function

Public Function grabarTiposUso(ByVal tipo_uso As String)

Dim strSQL As String
    
    strSQL = " INSERT INTO tipos_uso (tipo_uso) values ('" & tipo_uso & "')"
                                    
    If objCnxAeros.EjecutarComando(strSQL) Then
        grabarTiposUso = True
    Else
        grabarTiposUso = False
    End If

End Function

Public Function cargarTiposUso_by_ID(ByVal ID As Long)
Dim rs As New ADODB.Recordset
Dim strSQL As String
   
   strSQL = " SELECT id_tipo_uso, tipo_uso, " & _
            " fecha_baja FROM tipos_uso WHERE id_tipo_uso = " & ID
    
    Set rs = objCnxAeros.EjecutarConsulta(strSQL)
    
    AsignarValores rs

End Function










